﻿using System;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.UI.Security.Services;
using Sinacor.UI.Bovespa.Contabil.Communication.Bovespa.Ordens.Negocio;

namespace Sinacor.UI.Bovespa.Contabil.Communication
{
    /// <summary>
    /// Communication Class - Negocio
    /// </summary>
    public class Negocio : BaseCommunication
    {
        #region Construtor

        /// <summary>
        /// Construtor
        /// </summary>
        /// <param name="session">SessionInformation</param>
        public Negocio(SessionInformation session) : base(session) { }

        #endregion

        #region ConsultarBolsas

        /// <summary>
        /// Consulta Bolsas
        /// </summary>
        /// <returns>Lista de objetos do tipo Model.Bolsa</returns>
        public ModelCollection<Model.Bolsa> ConsultarBolsas()
        {
            try
            {
                using (ServiceInstance<INegocio> service = new ServiceInstance<INegocio>())
                {
                    INegocio servico = service.TryGetInstance(this.Session);

                    return new Translator.DataContractToModel.Negocio().ToBolsa(servico.ConsultarBolsas());
                }
            }
            catch (Exception ex)
            {
                this.HandleFault(ex);
                return null;
            }
        }

        #endregion
    }
}
